package com.yc;

import java.lang.annotation.*;

@A(ages = {1,2,3})
@WebServlet(value = "/hello.s", type="efg")
public class Demo2 {
    @A(name = "abc", ages = {1})
    int a;

    @A(name = "abc" , ages = 1)
    void test(@A(name = "abc", ages=2) int a){

    }

    @Override
    public String toString() {
        return "Demo2{" +
                "a=" + a +
                '}';
    }

    public static void main(String[] args) {
        A a = Demo2.class.getAnnotation(A.class);
        System.out.println("a = " + a);

        A a1 = SubDemo2.class.getAnnotation(A.class);
        System.out.println("a1 = " + a1);
    }
}

@Target({ElementType.TYPE,ElementType.FIELD,
        ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@interface A {
    String name() default "abc";
    int[] ages();
}

@Target(ElementType.TYPE)
@interface WebServlet{
    String value();
    String type() default "abc";
}

class SubDemo2 extends Demo2{

}